<!-- 我的表格 -->

<template>
  <WebTable class="RepairList-MyTable">
    <RowIndex />

    <RowTitle label="任务编号" bind="taskCode" />

    <RowDict v-if="!INIT_PARAM.planType" label="任务类型" bind="planType" :dict="DICT.TYPE" suffix="任务" />

    <RowText label="所属计划" bind="planName" :minWidth="120" />

    <RowText label="负责人" bind="principalUserName" />

    <RowTime label="创建时间" bind="createTime" width="auto" />

    <RowText label="执行时间" bind="exePeriod" :minWidth="160" />

    <RowStatus label="任务状态" bind="handleStatus" :dict="GETTER.STATUS" :width="150">
      <template #default="{ row, text, props }">
        <div :class="getStatusClass(row)">
          <span v-bind="props">{{ text }}</span>
        </div>
      </template>
    </RowStatus>

    <RowOperate :width="120">
      <template #default="{ row }">
        <BtnText title="查看" @click="windowDetail(row)" />

        <BtnText v-if="row.handleStatus === 3" title="审核" @click="openRelease(row)" />
        <BtnText v-if="row.handleStatus === 2" title="撤销" red @click="openCancel(row)" />
      </template>
    </RowOperate>
  </WebTable>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import mixDetailToTable from '@admin/components/detail/mixDetailToTable'
import TaskFooter from '@admin/components/detail/DetailTask/TaskFooter'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyTable',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [
    mixDetailToTable('', 'DetailTask'),
    CORE.mixWeb('deal', 'deal_'),
  ],

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听处理的修改就绪
     */
    deal_readyEdit(ready) {
      // 刷新列表
      ready && this.startList()
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    ...TaskFooter.methods,

    /**
     * 获取状态样式类
     */
    getStatusClass(row) {
      return row.timeout === 1 ? 'DetailRepair-RepairBase-timeout-1' : null
    },
  },
}
</script>

<style lang="scss">
@import '@admin/views/Maintain/Repair/RepairList/MyTable/index.scss';
</style>
